GtkPlacesViewPrivate *priv;
GVolume *volume;
GMount *mount;
+ GFile *file;
priv = gtk_places_view_get_instance_private (view);
mount = gtk_places_view_row_get_mount (row);
volume = gtk_places_view_row_get_volume (row);
+ file = gtk_places_view_row_get_file (row);
- if (mount)
+ if (file)
+ {
+ emit_open_location (view, file, flags);
+ }
+ else if (mount)
{
GFile *location = g_mount_get_root (mount);
- emit_open_location (view, location, GTK_PLACES_OPEN_NORMAL);
+ emit_open_location (view, location, flags);
g_object_unref (location);
}
"path", path ? path : "",
"volume", volume,
"mount", mount,
+ "file", NULL,
NULL);
insert_row (view, row, is_network);
"path", path ? path : "",
"volume", NULL,
"mount", mount,
+ "file", NULL,
NULL);
insert_row (view, row, is_network);
g_list_free_full (volumes, g_object_unref);
}
+static void
+add_computer (GtkPlacesView *view)
+{
+ GtkWidget *row;
+ GIcon *icon;
+ GFile *file;
+
+ file = g_file_new_for_path ("/");
+ icon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
+
+ row = g_object_new (GTK_TYPE_PLACES_VIEW_ROW,
+ "icon", icon,
+ "name", _("Computer"),
+ "path", "/",
+ "volume", NULL,
+ "mount", NULL,
+ "file", file,
+ NULL);
+
+ insert_row (view, row, FALSE);
+}
+
static void
update_places (GtkPlacesView *view)
{
gtk_widget_hide (priv->drives_box);
gtk_widget_hide (priv->network_grid);
+ /* Add "Computer" row */
+ add_computer (view);
+
/* Add currently connected drives */
drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
GVolume *volume;
GMount *mount;
+ GFile *file;
};
G_DEFINE_TYPE (GtkPlacesViewRow, gtk_places_view_row, GTK_TYPE_LIST_BOX_ROW)
PROP_PATH,
PROP_VOLUME,
PROP_MOUNT,
+ PROP_FILE,
LAST_PROP
};
g_value_set_object (value, self->mount);
break;
+ case PROP_FILE:
+ g_value_set_object (value, self->file);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
gtk_widget_set_visible (GTK_WIDGET (self->eject_button), self->mount != NULL);
break;
+ case PROP_FILE:
+ self->file = g_value_get_object (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
G_TYPE_MOUNT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ properties[PROP_FILE] =
+ g_param_spec_object ("file",
+ P_("File represented by the row"),
+ P_("The file represented by the row, if any"),
+ G_TYPE_FILE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
g_object_class_install_properties (object_class, LAST_PROP, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkplacesviewrow.ui");
return row->volume;
}
+GFile*
+gtk_places_view_row_get_file (GtkPlacesViewRow *row)
+{
+ g_return_val_if_fail (GTK_IS_PLACES_VIEW_ROW (row), NULL);
+
+ return row->file;
+}
+
GtkWidget*
gtk_places_view_row_get_eject_button (GtkPlacesViewRow *row)
{